package com.ymatou.userservice.testcase;

import java.io.IOException;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import org.apache.http.client.ClientProtocolException;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.userservice.parameter.AliUserRequestDtoBean;
import com.ymatou.userservice.parameter.PasswordRequestDtoBean;
import com.ymatou.userservice.parameter.SinaWeiBoUserRequestDtoBean;
import com.ymatou.userservice.parameter.UserSafeLevelInfoDtoBean;
import com.ymatou.userservice.parameter.WeiXinUserRequestDtoBean;
import com.ymatou.userservice.service.AliUserRequestDtoCall;
import com.ymatou.userservice.service.PasswordRequestDtoCall;
import com.ymatou.userservice.service.SinaWeiBoUserRequestDtoCall;
import com.ymatou.userservice.service.UserSafeLevelInfoDtoCall;
import com.ymatou.userservice.service.WeiXinUserRequestDtoCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.TestCase;
import com.ymt.utils.annotation.TestSuite;
import com.ymt.utils.tag.P1;
import com.ymttest.business.service.AuthCallService;
import com.ymttest.business.service.UserCallService;
import com.ymttest.database.mongo.ULC201406Bean;
import com.ymttest.database.mongo.ULC201406Wapper;
import com.ymttest.database.sqlwapper.YmtUsersWapper;
import com.ymttest.utils.TestDataManager;
import com.ymttest.utils.YMTDateUtil;
import com.ymttest.utils.constant.AppTypeChannel;
import com.ymttest.utils.constant.ECode;
import com.ymttest.utils.constant.ThirdPartyType;

/**
*获取用户安全等级接口
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_UserSafeLevelInfoDto{
	private static UserSafeLevelInfoDtoBean usersafelevelinfodtoBean;
	private static UserSafeLevelInfoDtoCall usersafelevelinfodtoCall;
	private static YmtUsersWapper userWapper;
	private static ULC201406Wapper mongoUser; 
	
	@BeforeClass
	public static void setUp() throws Exception {
		Logger.createResultFile("获取用户安全等级接口");
		userWapper = new YmtUsersWapper();
		mongoUser = new ULC201406Wapper();
	}

	@Before
	public void caseUp() {
		usersafelevelinfodtoBean=new UserSafeLevelInfoDtoBean();
		usersafelevelinfodtoCall=new UserSafeLevelInfoDtoCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(usersafelevelinfodtoCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_UserSafeLevelInfoDto_001() {
		Logger.start(true,"通过微信授权登陆，安全等级验证");
		try {
			Logger.comment("新创建微信账号");
			Map user = regByWeiXin();
			int userId = ((Double)user.get("userId")).intValue();
			String loginPas = "654321";
			usersafelevelinfodtoBean.setUserId(userId);
			usersafelevelinfodtoCall.setData(usersafelevelinfodtoBean);
			usersafelevelinfodtoCall.callService();			
			Logger.verifyEquals(ECode.SUCCESS, usersafelevelinfodtoCall.getString("ResponseCode"), "验证Code");
			Logger.verifyEquals("ok", usersafelevelinfodtoCall.getString("SuccessMessage"), "验证Msg信息");
			Logger.verifyEquals("true", usersafelevelinfodtoCall.getString("Success"), "验证操作是否成功");
			Logger.verifyEquals("0", usersafelevelinfodtoCall.getString("Result"), "验证安全等级为低级");
			
			Logger.comment("设置登陆密码");
			setLoginPas("modifyLoginPassword", userId, loginPas);
			Logger.comment("验证用户安全等级");
			usersafelevelinfodtoCall.callService();			
			Logger.verifyEquals(ECode.SUCCESS, usersafelevelinfodtoCall.getString("ResponseCode"), "验证Code");
			Logger.verifyEquals("ok", usersafelevelinfodtoCall.getString("SuccessMessage"), "验证Msg信息");
			Logger.verifyEquals("true", usersafelevelinfodtoCall.getString("Success"), "验证操作是否成功");
			Logger.verifyEquals("0", usersafelevelinfodtoCall.getString("Result"), "验证安全等级");
			
			Logger.comment("绑定手机号");
			UserCallService.bindPhone(userId, user.get("loginId").toString(), loginPas);
			Logger.comment("验证用户安全等级");
			usersafelevelinfodtoCall.callService();			
			Logger.verifyEquals(ECode.SUCCESS, usersafelevelinfodtoCall.getString("ResponseCode"), "验证Code");
			Logger.verifyEquals("ok", usersafelevelinfodtoCall.getString("SuccessMessage"), "验证Msg信息");
			Logger.verifyEquals("true", usersafelevelinfodtoCall.getString("Success"), "验证操作是否成功");
			Logger.verifyEquals("0", usersafelevelinfodtoCall.getString("Result"), "验证安全等级");
			
			Logger.comment("设置交易密码");
			setLoginPas("ModifyTradingPassword", userId, "123456");
			Logger.comment("验证用户安全等级");
			usersafelevelinfodtoCall.callService();			
			Logger.verifyEquals(ECode.SUCCESS, usersafelevelinfodtoCall.getString("ResponseCode"), "验证Code");
			Logger.verifyEquals("ok", usersafelevelinfodtoCall.getString("SuccessMessage"), "验证Msg信息");
			Logger.verifyEquals("true", usersafelevelinfodtoCall.getString("Success"), "验证操作是否成功");
			Logger.verifyEquals("0", usersafelevelinfodtoCall.getString("Result"), "验证安全等级");
			
			Logger.comment("绑定邮箱");
			UserCallService.bindEmail(userId, user.get("loginId").toString(), loginPas);
			Thread.sleep(1000);
			Logger.comment("验证用户安全等级");
			usersafelevelinfodtoCall.callService();			
			Logger.verifyEquals(ECode.SUCCESS, usersafelevelinfodtoCall.getString("ResponseCode"), "验证Code");
			Logger.verifyEquals("ok", usersafelevelinfodtoCall.getString("SuccessMessage"), "验证Msg信息");
			Logger.verifyEquals("true", usersafelevelinfodtoCall.getString("Success"), "验证操作是否成功");
			Logger.verifyEquals("1", usersafelevelinfodtoCall.getString("Result"), "验证安全等级");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_UserSafeLevelInfoDto_002() {
		Logger.start(true,"通过微博授权登陆，安全等级验证");
		try {
			Logger.comment("新创建微博账号");
			Map user = regByWeibo();
			int userId = ((Double)user.get("userId")).intValue();
			usersafelevelinfodtoBean.setUserId(userId);
			usersafelevelinfodtoCall.setData(usersafelevelinfodtoBean);
			usersafelevelinfodtoCall.callService();			
			Logger.verifyEquals(ECode.SUCCESS, usersafelevelinfodtoCall.getString("ResponseCode"), "验证Code");
			Logger.verifyEquals("ok", usersafelevelinfodtoCall.getString("SuccessMessage"), "验证Msg信息");
			Logger.verifyEquals("true", usersafelevelinfodtoCall.getString("Success"), "验证操作是否成功");
			Logger.verifyEquals("0", usersafelevelinfodtoCall.getString("Result"), "验证安全等级为低级");
			
			Logger.comment("设置交易密码");
			setLoginPas("ModifyTradingPassword", userId, "123456");
			Logger.comment("验证用户安全等级");
			usersafelevelinfodtoCall.callService();			
			Logger.verifyEquals(ECode.SUCCESS, usersafelevelinfodtoCall.getString("ResponseCode"), "验证Code");
			Logger.verifyEquals("ok", usersafelevelinfodtoCall.getString("SuccessMessage"), "验证Msg信息");
			Logger.verifyEquals("true", usersafelevelinfodtoCall.getString("Success"), "验证操作是否成功");
			Logger.verifyEquals("0", usersafelevelinfodtoCall.getString("Result"), "验证安全等级");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_UserSafeLevelInfoDto_003() {
		Logger.start(true,"通过阿里授权登陆，安全等级为低级");
		try {
			Logger.comment("查找一个未绑定过手机号的微博账号");
			Map user = userWapper.getThirdPartyNotBindPhone("Ymt_User_At_SinaWeibo", "YmatouUserId");
			int userId = (Integer)user.get("YmatouUserId");
			Logger.comment("初始化该用户名的密码为 8ymatou.com");
			mongoUser.updatePwdToOriginal(userId);
			Logger.comment("设置该用户的邮箱为空");
			mongoUser.updateEmail(userId, "");
			
			String loginPas = "987654";
			usersafelevelinfodtoBean.setUserId(userId);
			usersafelevelinfodtoCall.setData(usersafelevelinfodtoBean);
			usersafelevelinfodtoCall.callService();			
			Logger.verifyEquals(ECode.SUCCESS, usersafelevelinfodtoCall.getString("ResponseCode"), "验证Code");
			Logger.verifyEquals("ok", usersafelevelinfodtoCall.getString("SuccessMessage"), "验证Msg信息");
			Logger.verifyEquals("true", usersafelevelinfodtoCall.getString("Success"), "验证操作是否成功");
			Logger.verifyEquals("0", usersafelevelinfodtoCall.getString("Result"), "验证安全等级为低级");
			
			Logger.comment("设置登陆密码");
			setLoginPas("modifyLoginPassword", userId, loginPas);
			Logger.comment("验证用户安全等级");
			usersafelevelinfodtoCall.callService();			
			Logger.verifyEquals(ECode.SUCCESS, usersafelevelinfodtoCall.getString("ResponseCode"), "验证Code");
			Logger.verifyEquals("ok", usersafelevelinfodtoCall.getString("SuccessMessage"), "验证Msg信息");
			Logger.verifyEquals("true", usersafelevelinfodtoCall.getString("Success"), "验证操作是否成功");
			Logger.verifyEquals("0", usersafelevelinfodtoCall.getString("Result"), "验证安全等级");
			
			Logger.comment("绑定邮箱");
			ULC201406Bean userM = mongoUser.getULCInfoByUid(userId);
			UserCallService.bindEmail(userId, userM.getlBills().getLoginId(), loginPas);
			Logger.comment("验证用户安全等级");
			usersafelevelinfodtoCall.callService();			
			Logger.verifyEquals(ECode.SUCCESS, usersafelevelinfodtoCall.getString("ResponseCode"), "验证Code");
			Logger.verifyEquals("ok", usersafelevelinfodtoCall.getString("SuccessMessage"), "验证Msg信息");
			Logger.verifyEquals("true", usersafelevelinfodtoCall.getString("Success"), "验证操作是否成功");
			Logger.verifyEquals("0", usersafelevelinfodtoCall.getString("Result"), "验证安全等级");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_UserSafeLevelInfoDto_004() {
		Logger.start(true,"手机号注册用户，设置过登陆密码，安全等级验证");
		try {
			Map user = UserCallService.registerUser(null, TestDataManager.getPhoneNum(),null);
			usersafelevelinfodtoBean.setUserId((Integer)user.get("userId"));
			usersafelevelinfodtoCall.setData(usersafelevelinfodtoBean);
			usersafelevelinfodtoCall.callService();			
			Logger.verifyEquals(ECode.SUCCESS, usersafelevelinfodtoCall.getString("ResponseCode"), "验证Code");
			Logger.verifyEquals("ok", usersafelevelinfodtoCall.getString("SuccessMessage"), "验证Msg信息");
			Logger.verifyEquals("true", usersafelevelinfodtoCall.getString("Success"), "验证操作是否成功");
			Logger.verifyEquals("0", usersafelevelinfodtoCall.getString("Result"), "验证安全等级");
			
			Logger.comment("绑定邮箱");
			UserCallService.bindEmail((Integer)user.get("userId"), user.get("loginId").toString(), "123456");
			Thread.sleep(1000);
			Logger.comment("验证用户安全等级");
			usersafelevelinfodtoCall.callService();			
			Logger.verifyEquals(ECode.SUCCESS, usersafelevelinfodtoCall.getString("ResponseCode"), "验证Code");
			Logger.verifyEquals("ok", usersafelevelinfodtoCall.getString("SuccessMessage"), "验证Msg信息");
			Logger.verifyEquals("true", usersafelevelinfodtoCall.getString("Success"), "验证操作是否成功");
			Logger.verifyEquals("1", usersafelevelinfodtoCall.getString("Result"), "验证安全等级");
			
			Logger.comment("设置交易密码");
			setLoginPas("ModifyTradingPassword", (Integer)user.get("userId"), "456789");
			Logger.comment("验证用户安全等级");
			usersafelevelinfodtoCall.callService();			
			Logger.verifyEquals(ECode.SUCCESS, usersafelevelinfodtoCall.getString("ResponseCode"), "验证Code");
			Logger.verifyEquals("ok", usersafelevelinfodtoCall.getString("SuccessMessage"), "验证Msg信息");
			Logger.verifyEquals("true", usersafelevelinfodtoCall.getString("Success"), "验证操作是否成功");
			Logger.verifyEquals("1", usersafelevelinfodtoCall.getString("Result"), "验证安全等级");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase
	@Ignore
	//新用户不存在邮箱注册用户了
	public void Tc_UserSafeLevelInfoDto_005() {
		Logger.start(true,"邮箱注册用户，设置过登陆密码，安全等级验证");
		try {
			Map user = UserCallService.registerUser(TestDataManager.getEmail(), null,null);
			usersafelevelinfodtoBean.setUserId((Integer)user.get("userId"));
			usersafelevelinfodtoCall.setData(usersafelevelinfodtoBean);
			usersafelevelinfodtoCall.callService();			
			Logger.verifyEquals(ECode.SUCCESS, usersafelevelinfodtoCall.getString("ResponseCode"), "验证Code");
			Logger.verifyEquals("ok", usersafelevelinfodtoCall.getString("SuccessMessage"), "验证Msg信息");
			Logger.verifyEquals("true", usersafelevelinfodtoCall.getString("Success"), "验证操作是否成功");
			Logger.verifyEquals("0", usersafelevelinfodtoCall.getString("Result"), "验证安全等级");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category(P1.class)
	@TestCase//只有手机号或只有邮箱，应该是不能解绑的
	public void Tc_UserSafeLevelInfoDto_006() {
		Logger.start(true,"通过绑定了手机的阿里授权登陆，安全等级验证");
		try {
			Logger.comment("新创建阿里账号");
			Map user = regByAli(TestDataManager.getPhoneNum());
			int userId = ((Double)user.get("userId")).intValue();
			Thread.sleep(1000);
			Logger.comment("验证安全等级");
			usersafelevelinfodtoBean.setUserId(userId);
			usersafelevelinfodtoCall.setData(usersafelevelinfodtoBean);
			usersafelevelinfodtoCall.callService();			
			Logger.verifyEquals(ECode.SUCCESS, usersafelevelinfodtoCall.getString("ResponseCode"), "验证Code");
			Logger.verifyEquals("ok", usersafelevelinfodtoCall.getString("SuccessMessage"), "验证Msg信息");
			Logger.verifyEquals("true", usersafelevelinfodtoCall.getString("Success"), "验证操作是否成功");
			Logger.verifyEquals("0", usersafelevelinfodtoCall.getString("Result"), "验证安全等级为低级");
			Thread.sleep(2000);
			Logger.comment("解绑第三方账号");
			Map result = UserCallService.unbindThirdParty(userId, user.get("thirdPartyId").toString(), ThirdPartyType.ALI);
			Logger.verifyEquals(300d, result.get("ResponseCode"), "验证Code");
			Logger.verifyEquals(false, result.get("Success"), "验证是否成功");
			Logger.verifyEquals("请设置登录账号及密码", result.get("LastErrorMessage"), "验证Msg信息");
			
			Logger.comment("验证安全等级");
			usersafelevelinfodtoCall.callService();			
			Logger.verifyEquals(ECode.SUCCESS, usersafelevelinfodtoCall.getString("ResponseCode"), "验证Code");
			Logger.verifyEquals("ok", usersafelevelinfodtoCall.getString("SuccessMessage"), "验证Msg信息");
			Logger.verifyEquals("true", usersafelevelinfodtoCall.getString("Success"), "验证操作是否成功");
			Logger.verifyEquals("0", usersafelevelinfodtoCall.getString("Result"), "验证安全等级");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_UserSafeLevelInfoDto_007() {
		Logger.start(true,"设置安全问题开启双重验证，安全等级为高级JIRACONN-2522");
		try {
			Logger.comment("新创建微信账号");
			Map user = regByWeiXin();
			int userId = ((Double)user.get("userId")).intValue();
			String loginPas = "654321";
			usersafelevelinfodtoBean.setUserId(userId);
			usersafelevelinfodtoCall.setData(usersafelevelinfodtoBean);
			usersafelevelinfodtoCall.callService();			
			Logger.verifyEquals(ECode.SUCCESS, usersafelevelinfodtoCall.getString("ResponseCode"), "验证Code");
			Logger.verifyEquals("ok", usersafelevelinfodtoCall.getString("SuccessMessage"), "验证Msg信息");
			Logger.verifyEquals("true", usersafelevelinfodtoCall.getString("Success"), "验证操作是否成功");
			Logger.verifyEquals("0", usersafelevelinfodtoCall.getString("Result"), "验证安全等级为低级");
			
			Logger.comment("设置登陆密码");
			setLoginPas("modifyLoginPassword", userId, loginPas);
			Logger.comment("验证用户安全等级");
			usersafelevelinfodtoCall=new UserSafeLevelInfoDtoCall();
			usersafelevelinfodtoCall.setData(usersafelevelinfodtoBean);
			usersafelevelinfodtoCall.callService();	
			Logger.verifyEquals(ECode.SUCCESS, usersafelevelinfodtoCall.getString("ResponseCode"), "验证Code");
			Logger.verifyEquals("ok", usersafelevelinfodtoCall.getString("SuccessMessage"), "验证Msg信息");
			Logger.verifyEquals("true", usersafelevelinfodtoCall.getString("Success"), "验证操作是否成功");
			Logger.verifyEquals("0", usersafelevelinfodtoCall.getString("Result"), "验证安全等级");
			
			Logger.comment("绑定手机号");
			UserCallService.bindPhone(userId, user.get("loginId").toString(), loginPas);
			Logger.comment("验证用户安全等级");
			usersafelevelinfodtoCall=new UserSafeLevelInfoDtoCall();
			usersafelevelinfodtoCall.setData(usersafelevelinfodtoBean);
			usersafelevelinfodtoCall.callService();			
			Logger.verifyEquals(ECode.SUCCESS, usersafelevelinfodtoCall.getString("ResponseCode"), "验证Code");
			Logger.verifyEquals("ok", usersafelevelinfodtoCall.getString("SuccessMessage"), "验证Msg信息");
			Logger.verifyEquals("true", usersafelevelinfodtoCall.getString("Success"), "验证操作是否成功");
			Logger.verifyEquals("0", usersafelevelinfodtoCall.getString("Result"), "验证安全等级");
			
			Logger.comment("设置交易密码");
			setLoginPas("ModifyTradingPassword", userId, "123456");
			Logger.comment("验证用户安全等级");
			usersafelevelinfodtoCall=new UserSafeLevelInfoDtoCall();
			usersafelevelinfodtoCall.setData(usersafelevelinfodtoBean);
			usersafelevelinfodtoCall.callService();			
			Logger.verifyEquals(ECode.SUCCESS, usersafelevelinfodtoCall.getString("ResponseCode"), "验证Code");
			Logger.verifyEquals("ok", usersafelevelinfodtoCall.getString("SuccessMessage"), "验证Msg信息");
			Logger.verifyEquals("true", usersafelevelinfodtoCall.getString("Success"), "验证操作是否成功");
			Logger.verifyEquals("0", usersafelevelinfodtoCall.getString("Result"), "验证安全等级");
			
			Logger.comment("绑定邮箱");
			UserCallService.bindEmail(userId, user.get("loginId").toString(), loginPas);
			Logger.comment("验证用户安全等级");
			usersafelevelinfodtoCall=new UserSafeLevelInfoDtoCall();
			usersafelevelinfodtoCall.setData(usersafelevelinfodtoBean);
			usersafelevelinfodtoCall.callService();			
			Logger.verifyEquals(ECode.SUCCESS, usersafelevelinfodtoCall.getString("ResponseCode"), "验证Code");
			Logger.verifyEquals("ok", usersafelevelinfodtoCall.getString("SuccessMessage"), "验证Msg信息");
			Logger.verifyEquals("true", usersafelevelinfodtoCall.getString("Success"), "验证操作是否成功");
			Logger.verifyEquals("1", usersafelevelinfodtoCall.getString("Result"), "验证安全等级");
			AuthCallService.setSecurityQuestion(userId);
			AuthCallService.setSecurity(userId, true);
			Logger.comment("验证用户安全等级");
			usersafelevelinfodtoCall=new UserSafeLevelInfoDtoCall();
			usersafelevelinfodtoCall.setData(usersafelevelinfodtoBean);
			usersafelevelinfodtoCall.callService();			
			Logger.verifyEquals(ECode.SUCCESS, usersafelevelinfodtoCall.getString("ResponseCode"), "验证Code");
			Logger.verifyEquals("ok", usersafelevelinfodtoCall.getString("SuccessMessage"), "验证Msg信息");
			Logger.verifyEquals("true", usersafelevelinfodtoCall.getString("Success"), "验证操作是否成功");
			Logger.verifyEquals("2", usersafelevelinfodtoCall.getString("Result"), "验证安全等级");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category(P1.class)
	@TestCase
	public void Tc_UserSafeLevelInfoDto_008() {
		Logger.start(true,"设置安全问题关闭双重验证，安全等级为高级JIRACONN-2522");
		try {
			Logger.comment("新创建微信账号");
			Map user = regByWeiXin();
			int userId = ((Double)user.get("userId")).intValue();
			String loginPas = "654321";
			usersafelevelinfodtoBean.setUserId(userId);
			usersafelevelinfodtoCall.setData(usersafelevelinfodtoBean);
			usersafelevelinfodtoCall.callService();			
			Logger.verifyEquals(ECode.SUCCESS, usersafelevelinfodtoCall.getString("ResponseCode"), "验证Code");
			Logger.verifyEquals("ok", usersafelevelinfodtoCall.getString("SuccessMessage"), "验证Msg信息");
			Logger.verifyEquals("true", usersafelevelinfodtoCall.getString("Success"), "验证操作是否成功");
			Logger.verifyEquals("0", usersafelevelinfodtoCall.getString("Result"), "验证安全等级为低级");
			
			Logger.comment("设置登陆密码");
			setLoginPas("modifyLoginPassword", userId, loginPas);
			Logger.comment("验证用户安全等级");
			usersafelevelinfodtoCall=new UserSafeLevelInfoDtoCall();
			usersafelevelinfodtoCall.setData(usersafelevelinfodtoBean);
			usersafelevelinfodtoCall.callService();	
			Logger.verifyEquals(ECode.SUCCESS, usersafelevelinfodtoCall.getString("ResponseCode"), "验证Code");
			Logger.verifyEquals("ok", usersafelevelinfodtoCall.getString("SuccessMessage"), "验证Msg信息");
			Logger.verifyEquals("true", usersafelevelinfodtoCall.getString("Success"), "验证操作是否成功");
			Logger.verifyEquals("0", usersafelevelinfodtoCall.getString("Result"), "验证安全等级");
			
			Logger.comment("绑定手机号");
			UserCallService.bindPhone(userId, user.get("loginId").toString(), loginPas);
			Logger.comment("验证用户安全等级");
			usersafelevelinfodtoCall=new UserSafeLevelInfoDtoCall();
			usersafelevelinfodtoCall.setData(usersafelevelinfodtoBean);
			usersafelevelinfodtoCall.callService();			
			Logger.verifyEquals(ECode.SUCCESS, usersafelevelinfodtoCall.getString("ResponseCode"), "验证Code");
			Logger.verifyEquals("ok", usersafelevelinfodtoCall.getString("SuccessMessage"), "验证Msg信息");
			Logger.verifyEquals("true", usersafelevelinfodtoCall.getString("Success"), "验证操作是否成功");
			Logger.verifyEquals("0", usersafelevelinfodtoCall.getString("Result"), "验证安全等级");
			
			Logger.comment("设置交易密码");
			setLoginPas("ModifyTradingPassword", userId, "123456");
			Logger.comment("验证用户安全等级");
			usersafelevelinfodtoCall=new UserSafeLevelInfoDtoCall();
			usersafelevelinfodtoCall.setData(usersafelevelinfodtoBean);
			usersafelevelinfodtoCall.callService();			
			Logger.verifyEquals(ECode.SUCCESS, usersafelevelinfodtoCall.getString("ResponseCode"), "验证Code");
			Logger.verifyEquals("ok", usersafelevelinfodtoCall.getString("SuccessMessage"), "验证Msg信息");
			Logger.verifyEquals("true", usersafelevelinfodtoCall.getString("Success"), "验证操作是否成功");
			Logger.verifyEquals("0", usersafelevelinfodtoCall.getString("Result"), "验证安全等级");
			
			Logger.comment("绑定邮箱");
			UserCallService.bindEmail(userId, user.get("loginId").toString(), loginPas);
			Logger.comment("验证用户安全等级");
			usersafelevelinfodtoCall=new UserSafeLevelInfoDtoCall();
			usersafelevelinfodtoCall.setData(usersafelevelinfodtoBean);
			usersafelevelinfodtoCall.callService();			
			Logger.verifyEquals(ECode.SUCCESS, usersafelevelinfodtoCall.getString("ResponseCode"), "验证Code");
			Logger.verifyEquals("ok", usersafelevelinfodtoCall.getString("SuccessMessage"), "验证Msg信息");
			Logger.verifyEquals("true", usersafelevelinfodtoCall.getString("Success"), "验证操作是否成功");
			Logger.verifyEquals("1", usersafelevelinfodtoCall.getString("Result"), "验证安全等级");
			AuthCallService.setSecurityQuestion(userId);
			AuthCallService.setSecurity(userId, false);
			Logger.comment("验证用户安全等级");
			usersafelevelinfodtoCall=new UserSafeLevelInfoDtoCall();
			usersafelevelinfodtoCall.setData(usersafelevelinfodtoBean);
			usersafelevelinfodtoCall.callService();			
			Logger.verifyEquals(ECode.SUCCESS, usersafelevelinfodtoCall.getString("ResponseCode"), "验证Code");
			Logger.verifyEquals("ok", usersafelevelinfodtoCall.getString("SuccessMessage"), "验证Msg信息");
			Logger.verifyEquals("true", usersafelevelinfodtoCall.getString("Success"), "验证操作是否成功");
			Logger.verifyEquals("1", usersafelevelinfodtoCall.getString("Result"), "验证安全等级");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	/**
	 * 创建微信账号
	 * @throws IOException 
	 * @throws ClientProtocolException 
	 */
	private Map regByWeiXin() throws ClientProtocolException, IOException{
		WeiXinUserRequestDtoBean regBean = new WeiXinUserRequestDtoBean();
		WeiXinUserRequestDtoCall regCall = new WeiXinUserRequestDtoCall();
		String loginId = "LoginWeiXiUser_"+TestDataManager.getRandomNum(5);
		String openId = "RegopenId_"+TestDataManager.getRandomNum(7);
		regBean.setCountry("China");
		regBean.setProvince("Shanghai");
		regBean.setCity("Shanghai");
		regBean.setClientIp("1.1.1.1");
		regBean.setHeadimgurl("");
		regBean.setName(loginId);
		regBean.setOId(openId);
		regBean.setRegSource("MainSite");
		regBean.setMobile(TestDataManager.getPhoneNum());
		regBean.setSex("Femail");
		regBean.setTimeOut(new Date().getTime());
		regBean.setAppTypeChanndel(AppTypeChannel.NEW_CHANNEL);
		regBean.setTSource("Pc");
		regBean.setUnionId("unionId_"+TestDataManager.getRandomNum(4));
		regBean.setWeixinToken("weixintoken_"+TestDataManager.getRandomNum(10));
		
		regCall.setData(regBean);
		regCall.callService();	
		if(regCall.getString("Success").equals("false")){
			regCall=new WeiXinUserRequestDtoCall();
			regBean.setUnionId("unionId_"+TestDataManager.getRandomNum(4));
			regBean.setWeixinToken("weixintoken_"+TestDataManager.getRandomNum(10));
			regCall.setData(regBean);
			regCall.callService();	
		}
		Map<String, Object> user = new HashMap<String, Object>();
		user.put("userId", regCall.getResult().get("UserId"));
		user.put("loginId", loginId);
		return user;
	}
	
	/**
	 * 创建微博账号
	 * @return
	 * @throws IOException 
	 * @throws ClientProtocolException 
	 */
	private Map regByWeibo() throws ClientProtocolException, IOException{
		SinaWeiBoUserRequestDtoBean regBean = new SinaWeiBoUserRequestDtoBean();
		SinaWeiBoUserRequestDtoCall regCall = new SinaWeiBoUserRequestDtoCall();
		String loginId = "BindWeibo_"+TestDataManager.getRandomNum(10);
		regBean.setSWeiboUserId(loginId);
		regBean.setSName(loginId);
		regBean.setSMail(TestDataManager.getEmail());
		regBean.setSMobile(TestDataManager.getPhoneNum());
		regBean.setClientIp("120.1.1.1");
		regBean.setDAddTime(YMTDateUtil.getBeforeOrNextDay(-1));
		regBean.setTerminalSource("ios");
		regBean.setRegSource(1);
		regBean.setMobile(TestDataManager.getPhoneNum());
		regBean.setAppTypeChanndel(AppTypeChannel.NEW_CHANNEL);
		regCall.setData(regBean);
		regCall.callService();	
		Logger.verifyEquals("注册成功", regCall.getString("SuccessMessage"), "验证返回的Message信息");
		
		Map<String, Object> user = new HashMap<String, Object>();
		user.put("userId", regCall.getResult().get("UserId"));
		user.put("loginId", loginId);
		return user;
	} 
	
	/**
	 * 创建阿里账号
	 * @return
	 * @throws IOException 
	 * @throws ClientProtocolException 
	 */
	private Map regByAli(String phone) throws ClientProtocolException, IOException{
		AliUserRequestDtoBean aliuserregbean = new AliUserRequestDtoBean();
		AliUserRequestDtoCall aliuserregCall = new AliUserRequestDtoCall();
		String aliUserId = "ali_"+TestDataManager.getRandomNum(7);
		aliuserregbean.setSAliUserId(aliUserId);
		aliuserregbean.setSRealName(aliUserId);
		aliuserregbean.setSEmail("12456@123.com");
		aliuserregbean.setRegSource(1);
		aliuserregbean.setTerminalSource("ios");
		aliuserregbean.setAppTypeChanndel(AppTypeChannel.NEW_CHANNEL);
		aliuserregbean.setClientIp("120.1.1.1");
		aliuserregbean.setTokenTimeOut((new Date()).getTime());
		if(phone!=null){
			aliuserregbean.setMobile(phone);
		}
		aliuserregCall.setData(aliuserregbean);
		aliuserregCall.callService();			
		Logger.verifyEquals("注册成功", aliuserregCall.getString("SuccessMessage"), "验证返回的Message信息");
				
		Map<String, Object> user = new HashMap<String, Object>();
		user.put("userId", aliuserregCall.getResult().get("UserId"));
		user.put("loginId", aliUserId);
		user.put("thirdPartyId", aliUserId);
		return user;
	} 
	
	/**
	 * 设置登陆密码(pasType: modifyLoginPassword)
	 * @param userId
	 * @throws ClientProtocolException
	 * @throws IOException
	 */
	private void setLoginPas(String pasType, int userId, String pwd) throws ClientProtocolException, IOException{
		PasswordRequestDtoBean lab = new PasswordRequestDtoBean();
		PasswordRequestDtoCall lac = new PasswordRequestDtoCall();
		lab.setAType("ByUserId");
		lab.setPasActionType(pasType);
		lab.setUserId(userId+"");
		lab.setNewPassword(pwd);
		lac.setData(lab);
		lac.callService();
		Logger.verifyEquals("Success", lac.getString("Result"), "验证密码修改成功");
	}
}